#include <bits/stdc++.h>
using namespace std;
int t,n,m,L,V,ans;
struct node{
    int d,v,a;
}car[100005];
int p[100005];
int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    cin>>t;
    while(t--)
    {
        ans=0;
        memset(car,0,sizeof car);
        memset(p,0,sizeof p);
        cin>>n>>m>>L>>V;
        for(int i=1;i<=n;i++)
        {
            cin>>car[i].d>>car[i].v>>car[i].a;
        }
        for(int i=1;i<=m;i++)
        {
            cin>>p[i];
        }
        for(int i=1;i<=n;i++)
        {
            int j=0;
            if(sqrt(car[i].v*car[i].v+2*car[i].a*(p[j]-car[i].d))>V)
            {
                ans++;
            }
        }
        cout<<ans<<" "<<m-1;
    }
    fclose(stdin);
    fclose(stdout);
    return 0;
}
